﻿using System;
using Microsoft.Xna.Framework.Input;

namespace ProjetCom.Model.Template
{
    class Barre : Element
    {

        override public Boolean IsMoove
        {
            get {
                KeyboardState keyboardState = Keyboard.GetState();
                return (keyboardState.IsKeyDown(Keys.Left) || keyboardState.IsKeyDown(Keys.Right));
            }
        }

        public Barre(int p_x, int p_y)
            : base(p_x, p_y)
        {
            m_name = "Barre";
        }

        override public void Update(Microsoft.Xna.Framework.GameTime _gameTime) { }

        public Boolean CanMooveLeft()
        {
            return m_x > 0;
        }
        public Boolean CanMooveRight()
        {
            return m_x < (1280 - Width);
        }
        public Boolean CanMooveTop()
        {
            return m_y > 0;
        }
        public Boolean CanMooveBottom()
        {
            return m_y < (720 - Width);
        }

        public void MooveLeft()
        {
            m_x -= 10;
        }
        public void MooveRight()
        {
            m_x += 10;
        }

        public void MooveTop()
        {
            m_y -= 10;
        }

        public void MooveBottom()
        {
            m_y += 10;
        }

        override public CoteCollision EnterCollision(Element Other)
        {

            if (this.Rectangle.Intersects(Other.Rectangle))
            {
                Other.Y = this.Y - Element.Height - 1;
                return Element.CoteCollision.top;
            }

            return CoteCollision.none;
        }

        override public void Collision(CoteCollision p_cote, Boolean p_moove) { }
    }
}
